#!/usr/bin/ruby
$:.unshift File.join(File.dirname(__FILE__))
require 'AWS/EC2'
require 'basic_configuration'
require 'aws_context'
require 'pp'

# Display information about all our snapshots.

if ARGV[0] == '-?' 
  puts "usage: list-snapshots [id-list]"
  exit 1
end

Signal.trap("INT") do
  exit 2
end

config = BasicConfiguration.new
ec2 = AwsContext.instance.ec2(*config.keys)
begin
  snapshots = ec2.describe_snapshots
#  pp snapshots
  snapshots.each do |ss|
    puts "#{ss[:snapshot_id]} #{ss[:volume_id]} #{ss[:progress]} #{ss[:status]}"
  end
rescue
  puts "error #{$!}"
  exit 1
end
